class Solution:
    def lengthOfLastWord(self, s: str) -> int:
        words = s.split(' ')
        while words[-1] == '':
            words.pop()
        return len(words[-1])

if __name__ == '__main__':
    s = Solution()
    print(s.lengthOfLastWord(s = "Hello World"))
    print(s.lengthOfLastWord(s = "   fly me   to   the moon  "))
    print(s.lengthOfLastWord(s = s = "luffy is still joyboy"))